<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="技术,分享,生活">
    <meta name="description" content="这里是anlondon,欢迎留言交流">
    <meta name="author" content="anlondon">
    
    <title>
        
            apache多版本PHP配置 |
        
        一座浮岛
    </title>
    
<link rel="stylesheet" href="/css/style.css">

    <link rel="shortcut icon" href="/images/logo_my.png">
    
<link rel="stylesheet" href="/fontawesome/css/fontawesome.min.css">

    
<link rel="stylesheet" href="/fontawesome/css/regular.min.css">

    
<link rel="stylesheet" href="/fontawesome/css/solid.min.css">

    
<link rel="stylesheet" href="/fontawesome/css/brands.min.css">

    <script id="hexo-configurations">
    let KEEP = window.KEEP || {};
    KEEP.hexo_config = {"hostname":"example.com","root":"/","language":"en","path":"search.json"};
    KEEP.theme_config = {"toc":{"enable":true,"number":true,"expand_all":true,"init_open":true},"style":{"primary_color":"#557ea2","logo":"/images/logo_my.png","favicon":"/images/logo_my.png","avatar":"/images/avatar_my.svg","font_size":null,"font_family":"STKaiti","hover":{"shadow":true,"scale":true},"first_screen":{"enable":true,"header_transparent":false,"background_img":"https://api.likepoems.com/img/nature","description":null,"font_color":null,"hitokoto":true},"scroll":{"progress_bar":false,"percent":false}},"local_search":{"enable":true,"preload":true},"code_copy":{},"code_block":{"tools":{"enable":true,"style":"default"},"highlight_theme":"obsidian"},"side_tools":{},"pjax":{"enable":true},"lazyload":{"enable":true},"comment":{"enable":true,"use":"valine","valine":{"appid":"v7SvjMu6zFX3LPmiYGos39qx-gzGzoHsz","appkey":"MlLOMElKkabjL3SHiqXhFWAW","placeholder":null},"gitalk":{"github_id":null,"github_admins":null,"repository":null,"client_id":null,"client_secret":null},"twikoo":{"env_id":null,"region":null,"version":"1.6.7"},"waline":{"server_url":null,"reaction":false,"version":2}},"post":{"author_label":{"enable":true,"auto":true,"custom_label_list":["Trainee","Engineer","Architect"]},"word_count":{"enable":true,"wordcount":true,"min2read":true},"img_align":"left","copyright_info":false},"version":"3.5.2"};
    KEEP.language_ago = {"second":"%s seconds ago","minute":"%s minutes ago","hour":"%s hours ago","day":"%s days ago","week":"%s weeks ago","month":"%s months ago","year":"%s years ago"};
    KEEP.language_code_block = {"copy":"Copy code","copied":"Copied","fold":"Fold code block","folded":"Folded"};
  </script>
<meta name="generator" content="Hexo 5.4.0"></head>


<body>
<!-- anlondon 加的 start -->
<div class="background-my"></div>
<!-- anlondon 加的 end-->
<div class="progress-bar-container">
    

    
        <span class="pjax-progress-bar"></span>
        <i class="pjax-progress-icon fas fa-circle-notch fa-spin"></i>
    
</div>


<main class="page-container">

    

    <div class="page-main-content">

        <div class="page-main-content-top">
            
<header class="header-wrapper">

    <div class="header-content">
        <div class="left">
            
                <a class="logo-image" href="/">
                    <img src="/images/logo_my.png">
                </a>
            
            <a class="logo-title" href="/">
               一座浮岛
            </a>
        </div>

        <div class="right">
            <div class="pc">
                <ul class="menu-list">
                    
                        <li class="menu-item">
                            <a class=""
                               href="/"
                            >
                                首页
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/archives"
                            >
                                时间流
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/categories"
                            >
                                归档
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/links"
                            >
                                LINKS
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/about"
                            >
                                关于
                            </a>
                        </li>
                    
                    
                        <li class="menu-item search search-popup-trigger">
                            <i class="fas fa-search"></i>
                        </li>
                    
                </ul>
            </div>
            <div class="mobile">
                
                    <div class="icon-item search search-popup-trigger"><i class="fas fa-search"></i></div>
                
                <div class="icon-item menu-bar">
                    <div class="menu-bar-middle"></div>
                </div>
            </div>
        </div>
    </div>

    <div class="header-drawer">
        <ul class="drawer-menu-list">
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/">首页</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/archives">时间流</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/categories">归档</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/links">LINKS</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/about">关于</a>
                </li>
            
        </ul>
    </div>

    <div class="window-mask"></div>

</header>


        </div>

        <div class="page-main-content-middle">

            <div class="main-content">

                
                    <div class="fade-in-down-animation">
    <div class="post-page-container">
        <div class="article-content-container">

            <div class="article-title">
                <span class="title-hover-animation">apache多版本PHP配置</span>
            </div>

            
                <div class="article-header">
                    <div class="avatar">
                        <img src="/images/avatar_my.svg">
                    </div>
                    <div class="info">
                        <div class="author">
                            <span class="name">anlondon</span>
                            
                                <span class="author-label">Lv6</span>
                            
                        </div>
                        <div class="meta-info">
                            
<div class="article-meta-info">
    <span class="article-date article-meta-item">
        
            <i class="fa-regular fa-calendar-plus"></i>&nbsp;
        
        <span class="pc">2021-03-07 21:16:00</span>
        <span class="mobile">2021-03-07 21:16</span>
    </span>
    
        <span class="article-update-date article-meta-item">
        <i class="fas fa-file-pen"></i>&nbsp;
        <span class="pc">2021-03-07 21:40:22</span>
    </span>
    
    
        <span class="article-categories article-meta-item">
            <i class="fas fa-folder"></i>&nbsp;
            <ul>
                
                    <li>
                        <a href="/categories/Apache/">Apache</a>&nbsp;
                    </li>
                
            </ul>
        </span>
    
    

    
    
    
    
        <span class="article-pv article-meta-item">
            <i class="fas fa-eye"></i>&nbsp;<span id="busuanzi_value_page_pv"></span>
        </span>
    
</div>

                        </div>
                    </div>
                </div>
            

            <div class="article-content keep-markdown-body">
                <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h1 id="导言"><a href="#导言" class="headerlink" title="导言"></a>导言</h1><p><strong>windows</strong> 用户见<a class="link"   target="_blank" rel="noopener" href="https://www.cnblogs.com/songlen/p/6613884.html" >windows - apache 配置多个版本的 php<i class="fas fa-external-link-alt"></i></a></p>
<p>因为项目需要，要在 Linux 上使用apache 部署多个 PHP 项目，且 不同项目的要用到不同的 PHP 版本，因此在这里记录下。</p>
<ul>
<li>Linux：CentOS7</li>
<li>Apache：2.4</li>
<li>PHP : 5.6 需要安装7.4</li>
</ul>
<h2 id="步骤"><a href="#步骤" class="headerlink" title="步骤"></a>步骤</h2><p>服务器使用的是阿里云的，里面已经集成了 Apache &amp; PHP5.6，可以直接使用他们配置的文件，这里只需要安装PHP7即可</p>
<h6 id="一、安装PHP7-4"><a href="#一、安装PHP7-4" class="headerlink" title="一、安装PHP7.4"></a>一、安装PHP7.4</h6><ul>
<li>访问<a class="link"   target="_blank" rel="noopener" href="https://www.php.net/downloads.php" >php官网下载列表<i class="fas fa-external-link-alt"></i></a>，找到PHP7.4,复制其下载链接。</li>
<li>阿里默认PHP安装在 /usr/local/ ,进入该目录，并下载PHP7.4到该目录</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">下载安装包</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> <span class="built_in">cd</span> /usr/<span class="built_in">local</span>/</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> wget https://www.php.net/distributions/php-7.4.15.tar.gz</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash">解压</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tar -zxvf php-7.4.15.tar.gz</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash">检查当前的环境是否满足要安装软件的依赖关系</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> <span class="built_in">cd</span> php-7.4.15</span></span><br><span class="line"><span class="meta">#</span><span class="bash">设置安装目录并编译检查依赖</span></span><br><span class="line"><span class="meta">#</span><span class="bash">可用 ./configure --<span class="built_in">help</span> 查看当前版本的可选项</span></span><br><span class="line"><span class="meta">#</span><span class="bash">注意参数中有  多个  php设置路径</span></span><br><span class="line"></span><br><span class="line">./configure --prefix=/usr/local/php74 --with-config-file-path=/usr/local/php74 --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype --with-jpeg --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-ftp --enable-gd --with-external-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-sodium --with-webp --enable-fpm</span><br></pre></td></tr></table></figure>

<blockquote>
<p>注意编译时安装路径的设置<br>上面的参数除了PHP程序的安装路径，还有其配置文件的路径<br>如果路径错误，会导致php无法正常运行，并且难以察觉<br>更多的选项见 <code>./configure --help</code><br><a class="link"   target="_blank" rel="noopener" href="https://www.cnblogs.com/hubing/p/3735452.html" >php编译参数注解<i class="fas fa-external-link-alt"></i></a>(该链接内容仅作参考，以<code>./configure –help</code>为准)</p>
<p>提示 Package ‘xxxx’, required by ‘virtual:world’, not found<br>php 源码安装常见问题汇总<br><a class="link"   target="_blank" rel="noopener" href="https://paragonie.com/book/pecl-libsodium/read/00-intro.md#installing-libsodium" >Installing Libsodium<i class="fas fa-external-link-alt"></i></a></p>
</blockquote>
<p>当<strong>出现下面的界面</strong>，则表示<strong>安装成功</strong><br><img  
                     lazyload
                     alt="image"
                     data-src="/2021/03/07/apache%E5%A4%9A%E7%89%88%E6%9C%ACPHP%E9%85%8D/pasted-0.png"
                      alt="一座浮岛"
                ></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">测试编译</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> make</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> make <span class="built_in">test</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash">(1)如果检查时出现某些依赖没有安装，则需要单独安装，不然会出现</span></span><br><span class="line"><span class="meta">#</span><span class="bash">make: *** No targets specified and no makefile found. Stop</span></span><br><span class="line"><span class="meta">#</span><span class="bash">(2)编译成功后出现某某选项无法识别</span></span><br><span class="line"><span class="meta">#</span><span class="bash">configure: WARNING: unrecognized options:...</span></span><br><span class="line"><span class="meta">#</span><span class="bash">见底部 相关资料</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash">安装</span></span><br><span class="line">make install</span><br></pre></td></tr></table></figure>

<ul>
<li>配置PHP.ini。 在之前编译的源码包中，找到 php.ini-production，复制到/usr/local/php下，并改名为php.ini<br><code>cp php.ini-production /usr/local/php74/php.ini</code></li>
</ul>
<p> [cgi]修改配置文件php.ini<br> <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">vim /usr/local/php74/php.ini</span><br><span class="line"><span class="meta">#</span><span class="bash">修改</span></span><br><span class="line">cgi.fix_pathinfo=0</span><br></pre></td></tr></table></figure><br> 见 <a class="link"   target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_39421014/article/details/80597062" >为什么php.ini设置cgi.fix_pathinfo=0<i class="fas fa-external-link-alt"></i></a></p>
<p> **[可选项]**设置让PHP错误信息打印在页面上<br> <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> vim /usr/<span class="built_in">local</span>/php74/php.ini</span></span><br><span class="line"></span><br><span class="line">display_errors = off</span><br></pre></td></tr></table></figure><br> 将 <code>Off</code> 改成 <code>On</code></p>
<ul>
<li>配置php-fpm<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">修改php-fpm配置文件：</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> <span class="built_in">cd</span> /usr/<span class="built_in">local</span>/php74/etc</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> cp php-fpm.conf.default php-fpm.conf</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> vim php-fpm.conf</span></span><br><span class="line"><span class="meta">#</span><span class="bash">去掉 pid = run/php-fpm.pid 前面的分号</span></span><br><span class="line"><span class="meta">#</span><span class="bash">开启错误日志，否则无法运行php-fpm</span></span><br><span class="line"><span class="meta">#</span><span class="bash">阿里云有配置过日志目录，因此使用 find / -name php-fpm.log 即可找到日志保存目录</span></span><br></pre></td></tr></table></figure>
配置<strong><a class="link"   target="_blank" rel="noopener" href="http://www.conf/" >www.conf<i class="fas fa-external-link-alt"></i></a></strong><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> <span class="built_in">cd</span> php-fpm.d</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> cp www.conf.default www.conf</span></span><br><span class="line"></span><br><span class="line"><span class="meta">$</span><span class="bash"> vim www.conf</span></span><br><span class="line"><span class="meta">#</span><span class="bash">(1)更改侦听端口为9001(9000 为默认端口)</span></span><br><span class="line"><span class="meta">#</span><span class="bash">(2)修改用户和组为当前用户(默认会添加nobody这个用户和用户组)</span></span><br></pre></td></tr></table></figure>
<img  
                     lazyload
                     alt="image"
                     data-src="/2021/03/07/apache%E5%A4%9A%E7%89%88%E6%9C%ACPHP%E9%85%8D/pasted-1.png"
                      alt="一座浮岛"
                ></li>
</ul>
<p> <img  
                     lazyload
                     alt="image"
                     data-src="/2021/03/07/apache%E5%A4%9A%E7%89%88%E6%9C%ACPHP%E9%85%8D/pasted-2.png"
                      alt="一座浮岛"
                ></p>
<ul>
<li>测试php-fpm是否安装成功<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta"> #</span><span class="bash">启动 php74 内的 php-fpm</span></span><br><span class="line">/usr/local/php74/sbin/php-fpm</span><br><span class="line"></span><br><span class="line"><span class="meta"> #</span><span class="bash">看是否有报错，没有任何提示，则说明 fpm 安装配置无误</span></span><br></pre></td></tr></table></figure></li>
</ul>
<p> <strong>查看是否启动成功</strong><br> <code>ps aux|grep php</code><br> <img  
                     lazyload
                     alt="image"
                     data-src="/2021/03/07/apache%E5%A4%9A%E7%89%88%E6%9C%ACPHP%E9%85%8D/pasted-3.png"
                      alt="一座浮岛"
                ></p>
<ul>
<li>添加 php-fpm 到系统服务内<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta"> #</span><span class="bash">将 fpm 管理程序放入系统</span></span><br><span class="line"><span class="meta"> $</span><span class="bash"> cp /usr/<span class="built_in">local</span>/php-7.4.15/sapi/fpm/init.d.php-fpm /etc/init.d/php74-fpm</span></span><br><span class="line"><span class="meta">#</span><span class="bash">添加可执行权限</span></span><br><span class="line"><span class="meta"> $</span><span class="bash"> chmod +x /etc/init.d/php74-fpm</span></span><br></pre></td></tr></table></figure></li>
</ul>
<p> 设置开机启动<br> <code>chkconfig --add /etc/init.d/php74-fpm</code></p>
<p> 更多命令<br> <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">service php74-fpm start #启动</span><br><span class="line">service php74-fpm restart #重启</span><br><span class="line">service php74-fpm stop #停止</span><br></pre></td></tr></table></figure></p>
<ul>
<li>php-fpm配置文件参数解释<br>见 <a class="link"   target="_blank" rel="noopener" href="https://www.jb51.net/article/42716.htm" >脚本之家|配置php-fpm参数及配置详解<i class="fas fa-external-link-alt"></i></a></li>
</ul>
<p><strong>需要注意的地方</strong></p>
<ol>
<li><code>./configure</code> 编译参数时，使用 <code>./configure --help</code>查看<strong>当前版本的编译参数</strong></li>
<li>编译安装时，设置PHP安装路径有两种方式,见<a class="link"   target="_blank" rel="noopener" href="https://www.cnblogs.com/lenmom/p/10189140.html" >Linux下指定pip install和make install安装路径<i class="fas fa-external-link-alt"></i></a></li>
<li>并没有找到一个 fpm 管理多个 php 的办法,因此启动多版本PHP需要多个相应的 fpm</li>
</ol>
<h6 id="配置apache"><a href="#配置apache" class="headerlink" title="配置apache"></a>配置apache</h6><ul>
<li>安装mod_fcgid.so,该模块可以支持 apache 运行多版本的 php.</li>
</ul>
<blockquote>
<p>请根据apache版本选择对应版本的mod_fcgid.so，这里以apache2.4为例</p>
</blockquote>
 <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">下载</span></span><br><span class="line"><span class="meta">$</span><span class="bash"><span class="built_in">cd</span> /usr/<span class="built_in">local</span>/src</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/mod_fcgid/mod_fcgid-2.3.9.tar.gz</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash">解压安装</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tar -zxvf mod_fcgid-2.3.9.tar.gz</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> <span class="built_in">cd</span> mod_fcgid-2.3.9</span></span><br><span class="line"></span><br><span class="line"><span class="meta">$</span><span class="bash"> APXS=/usr/<span class="built_in">local</span>/apache/bin/apxs ./configure.apxs</span></span><br><span class="line"></span><br><span class="line"><span class="meta">$</span><span class="bash"> make</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> make install</span></span><br></pre></td></tr></table></figure>

<ul>
<li>修改httpd.conf , 安装好该模块后，httpd.conf 会自动添加加载该模块。<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">备份httpd.conf</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> cp /usr/<span class="built_in">local</span>/apache/httpd.conf /usr/<span class="built_in">local</span>/apache/httpd.conf.bak</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash">编辑设置 mod_fcgi</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> vim /usr/<span class="built_in">local</span>/apache/conf/httpd.conf</span></span><br><span class="line"><span class="meta">#</span><span class="bash">查找是存在mod_fcgid模块</span></span><br><span class="line">/mod_fcgid/</span><br><span class="line"><span class="meta">#</span><span class="bash">需要其开启，没有则手动添加</span> </span><br><span class="line">LoadModule fcgid_module modules/mod_fcgid.so</span><br><span class="line">FcgidMaxProcesses 1000 #php-cgi最大的进程数</span><br><span class="line">MaxRequestLen 52428800 #php程序最大文件上传限制50mb 默认为131072（128kb）</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash">读取并运行 php 文件</span></span><br><span class="line"><span class="meta">#</span><span class="bash">找到AddType application/x-gzip .gz .tgz</span></span><br><span class="line"><span class="meta">#</span><span class="bash">在该行下面添加</span></span><br><span class="line">AddType application/x-httpd-php .php</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash">保存退出</span></span><br><span class="line">:wq!  </span><br></pre></td></tr></table></figure></li>
</ul>
<blockquote>
<p>apache php fastcgi模式下，默认上传文件大小只有131072字节（128kb），需要在apache的配置文件中修改<br>fastcgi模式下，在php.ini中修改upload_max_filesize等参数无效。</p>
</blockquote>
<ul>
<li>配置虚拟机<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta"> $</span><span class="bash"> vim /usr/<span class="built_in">local</span>/apache/conf/httpd.conf</span></span><br><span class="line"></span><br><span class="line"><span class="meta"> #</span><span class="bash">找到 <span class="comment">#Include conf/extra/httpd-vhosts.conf,取消注释</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash">保存退出</span></span><br><span class="line"></span><br><span class="line"><span class="meta"> $</span><span class="bash"> vim /usr/<span class="built_in">local</span>/apache/conf/extra/httpd-vhost.conf</span></span><br><span class="line"><span class="meta"> #</span><span class="bash">里面给出了一个虚拟机配置模板按照该模板配置即可</span></span><br></pre></td></tr></table></figure></li>
</ul>
<p> <img  
                     lazyload
                     alt="image"
                     data-src="/2021/03/07/apache%E5%A4%9A%E7%89%88%E6%9C%ACPHP%E9%85%8D/pasted-4.png"
                      alt="一座浮岛"
                ></p>
<p> 如图，建立了两个虚拟机，并指定了不同的PHP</p>
<p> 访问一下<br> <img  
                     lazyload
                     alt="image"
                     data-src="/2021/03/07/apache%E5%A4%9A%E7%89%88%E6%9C%ACPHP%E9%85%8D/pasted-5.png"
                      alt="一座浮岛"
                ></p>
<p> 再试试另一个<br> <img  
                     lazyload
                     alt="image"
                     data-src="/2021/03/07/apache%E5%A4%9A%E7%89%88%E6%9C%ACPHP%E9%85%8D/pasted-6.png"
                      alt="一座浮岛"
                ></p>
<p>成功</p>
<p><strong>需要注意的地方</strong></p>
<ol>
<li>需要添加 <code>AddType application/x-httpd-php .php</code> 才能使解析php文件</li>
<li>apache2.4 允许外部访问 参数简化为 <code>Require all granted</code>,之前版本为<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">AllowOverride All</span><br><span class="line">Order allow,deny</span><br><span class="line">Allow from all</span><br></pre></td></tr></table></figure></li>
</ol>
<hr>
<p><strong>相关资料</strong>:</p>
<ul>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.cnblogs.com/houss/p/11296285.html" >Linux 安装php7<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://segmentfault.com/a/1190000009875949" >centos6.5 源码安装php7<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.cnblogs.com/liubaoqing/p/12176017.html" >centos7 编译安装 php7.4<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.yanglong.pro/centos8-%e5%ae%89%e8%a3%85-oniguruma-devel/" >Package ‘oniguruma’, required by ‘virtual:world’, not found<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.cnblogs.com/zhangyouwu/p/12603893.html" >linux安装php遇到的No package ‘sqlite3’ found，解决方法:yum install sqlite-devel<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.jianshu.com/p/d01665bfa4eb" >CentOS 7编译安装PHP 7.4提示No package ‘libzip’ found或者(libzip &gt;= 0.11)<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.debugnode.com/ubuntul_ibsodium/" >安装libsodium库解决libsodium not found问题<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://paragonie.com/book/pecl-libsodium/read/00-intro.md#installing-libsodium" >编Installing Libsodium and the PHP extension<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://blog.csdn.net/dannyiscoder/article/details/78455909" >make: *** No targets specified and no makefile found. Stop<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.inbeijing.org/archives/2079" >configure: error: Package requirements (sqlite3 &gt; 3.7.4) were not met: No package ‘sqlite3’ found<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.yanglong.pro/configure-warning-unrecognized-options-with-gd/" >configure: WARNING: unrecognized options: –with-gd<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.cnblogs.com/lenmom/p/10189140.html" >Linux下指定pip install和make install安装路径<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.cnblogs.com/RainBol/p/10717036.html" >phpenv - php多版本配置<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.cnblogs.com/jackzhuo/p/12761035.html" >Linux 安装多个php版本并配置<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.cnblogs.com/songlen/p/6613884.html" >windows - apache 配置多个版本的 php<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://blog.csdn.net/b1303110335/article/details/77935245" >php的cgi.fix_pathinfo解析<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://blog.csdn.net/qq_34908844/article/details/77899605" >配置 php-fpm 时出现’/private/etc/php-fpm.conf’: No such file or directory (2)<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_39421014/article/details/80597062" >为什么php.ini设置cgi.fix_pathinfo=0<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.osyunwei.com/archives/10174.html" >Linux下apache虚拟主机配置多版本php同时运行<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.jb51.net/article/42716.htm" >脚本之家|配置php-fpm参数及配置详解<i class="fas fa-external-link-alt"></i></a></li>
<li><a class="link"   target="_blank" rel="noopener" href="https://www.rootop.org/pages/109.html" >apache 虚拟目录错误：CustomLog takes two or three arguments, a file name, a custom log format string or format name, and an optional “env=” clause<i class="fas fa-external-link-alt"></i></a></li>
</ul>

            </div>

            

            

            
                <div class="article-nav">
                    
                        <div class="article-prev">
                            <a class="prev"
                               rel="prev"
                               href="/2021/03/07/%E9%99%A4%E9%9D%9EWindows-Activation-Service%EF%BC%88WAS%EF%BC%89%E5%92%8C%E4%B8%87%E7%BB%B4%E7%BD%91%E5%8F%91%E5%B8%83%E6%9C%8D%E5%8A%A1%EF%BC%88W3SVC%EF%BC%89%E5%9D%87%E5%A4%84%E4%BA%8E%E8%BF%90%E8%A1%8C%E7%8A%B6%E6%80%81%EF%BC%8C%E5%90%A6%E5%88%99%E6%97%A0%E6%B3%95%E5%90%AF%E5%8A%A8%E7%BD%91%E7%AB%99%E3%80%82%E7%9B%AE%E5%89%8D%EF%BC%8C%E8%BF%99%E4%B8%A4%E9%A1%B9%E6%9C%8D%E5%8A%A1%E5%9D%87%E5%A4%84%E4%BA%8E%E5%81%9C%E6%AD%A2%E7%8A%B6%E6%80%81%E3%80%82/"
                            >
                            <span class="left arrow-icon flex-center">
                              <i class="fas fa-chevron-left"></i>
                            </span>
                                <span class="title flex-center">
                                <span class="post-nav-title-item">除非Windows Activation Service（WAS）和万维网发布服务（W3SVC）均处于运行状态，否则无法启动网站。目前，这两项服务均处于停止状态。</span>
                                <span class="post-nav-item">Prev posts</span>
                            </span>
                            </a>
                        </div>
                    
                    
                        <div class="article-next">
                            <a class="next"
                               rel="next"
                               href="/2021/03/07/No-input-file-specified/"
                            >
                            <span class="title flex-center">
                                <span class="post-nav-title-item">No input file specified</span>
                                <span class="post-nav-item">Next posts</span>
                            </span>
                                <span class="right arrow-icon flex-center">
                              <i class="fas fa-chevron-right"></i>
                            </span>
                            </a>
                        </div>
                    
                </div>
            

            
                <div class="comment-container">
                    
<div class="comments-container">
    <div id="comments-anchor"></div>
    <div class="comment-area-title">
        <i class="fas fa-comments"></i>&nbsp;Comments
    </div>
    
        
            

    <div class="valine-container">
        <script data-pjax src="//cdn.jsdelivr.net/npm/valine@latest/dist/Valine.min.js"></script>
        <div id="vcomments"></div>
        <script data-pjax>
          function loadValine() {
            new Valine({
              el: '#vcomments',
              appId: 'v7SvjMu6zFX3LPmiYGos39qx-gzGzoHsz',
              appKey: 'MlLOMElKkabjL3SHiqXhFWAW',
              meta: ['nick', 'mail', 'link'],
              avatar: 'wavatar',
              enableQQ: true,
              placeholder: '',
              lang: 'en'.toLowerCase()
            });

            function getAuthor(language) {
              switch (language) {
                case 'en':
                  return 'Author';
                case 'zh-CN':
                  return '博主';
                default:
                  return 'Master';
              }
            }

            // Add "Author" identify
            const getValineDomTimer = setInterval(() => {
              const vcards = document.querySelectorAll('#vcomments .vcards .vcard');
              if (vcards.length > 0) {
                let author = 'anlondon';

                if (author) {
                  for (let vcard of vcards) {
                    const vnick_dom = vcard.querySelector('.vhead .vnick');
                    const vnick = vnick_dom.innerHTML;
                    if (vnick === author) {
                      vnick_dom.innerHTML = `${vnick} <span class="author">${getAuthor(KEEP.hexo_config.language)}</span>`
                    }
                  }
                }
                clearInterval(getValineDomTimer);
              } else {
                clearInterval(getValineDomTimer);
              }
            }, 2000);
          }

          if ('true' === 'true') {
            const loadValineTimeout = setTimeout(() => {
              loadValine();
              clearTimeout(loadValineTimeout);
            }, 1000);
          } else {
            window.addEventListener('DOMContentLoaded', loadValine);
          }
        </script>
    </div>



        
    
</div>

                </div>
            
        </div>

        
            <div class="toc-content-container">
                <div class="post-toc-wrap">
    <div class="post-toc">
        <ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%AF%BC%E8%A8%80"><span class="nav-number">1.</span> <span class="nav-text">导言</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%AD%A5%E9%AA%A4"><span class="nav-number">1.1.</span> <span class="nav-text">步骤</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E5%AE%89%E8%A3%85PHP7-4"><span class="nav-number">1.1.0.0.0.1.</span> <span class="nav-text">一、安装PHP7.4</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#%E9%85%8D%E7%BD%AEapache"><span class="nav-number">1.1.0.0.0.2.</span> <span class="nav-text">配置apache</span></a></li></ol></li></ol></li></ol></li></ol></li></ol></li></ol>
    </div>
</div>

            </div>
        
    </div>
</div>


                
            </div>

        </div>

        <div class="page-main-content-bottom">
            
<footer class="footer">
    <div class="info-container">
        <div class="copyright-info info-item">
            &copy;
            
                <span>2020</span> -
            
            2023
            
                &nbsp;<i class="fas fa-heart icon-animate"></i>
                &nbsp;<a href="/">anlondon</a>
            
        </div>
        
            <script async data-pjax
                    src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
            <div class="website-count info-item">
                
                    Visitor Count&nbsp;<span id="busuanzi_value_site_uv"></span>&ensp;
                
                
                    Totalview&nbsp;<span id="busuanzi_value_site_pv"></span>
                
            </div>
        
        <div class="theme-info info-item">
            Powered by <a target="_blank" href="https://hexo.io">Hexo</a>&nbsp;|&nbsp;Theme&nbsp;<a class="theme-version" target="_blank" href="https://github.com/XPoet/hexo-theme-keep">Keep v3.5.2</a>
        </div>
        
            <div class="icp-info info-item">
                <a target="_blank" rel="nofollow"
                   href="https://beian.miit.gov.cn"
                >
                    蜀ICP备2021002582号
                </a>

                <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=51010602001866" style="display:inline-block;text-decoration:none;height:17px;line-height:17px;">
                    <img src="https://www.beian.gov.cn/img/new/gongan.png" style="float:left;"/>
                    <p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px;">川公网安备 51010602001866号</p>
                </a>

            </div>
        
        
    </div>
</footer>

        </div>
    </div>

    
        <div class="post-tools">
            <div class="post-tools-container">
    <ul class="tools-list">
        <!-- TOC aside toggle -->
        
            <li class="tools-item flex-center toggle-show-toc">
                <i class="fas fa-list"></i>
            </li>
        

        <!-- go comment -->
        
            <li class="tools-item flex-center go-to-comments">
                <i class="fas fa-comment"></i>
                <span class="post-comments-count"></span>
            </li>
        
    </ul>
</div>

        </div>
    

    <div class="right-bottom-side-tools">
        <div class="side-tools-container">
    <ul class="side-tools-list">
        <li class="tools-item tool-font-adjust-plus flex-center">
            <i class="fas fa-search-plus"></i>
        </li>

        <li class="tools-item tool-font-adjust-minus flex-center">
            <i class="fas fa-search-minus"></i>
        </li>

        <li class="tools-item tool-dark-light-toggle flex-center">
            <i class="fas fa-moon"></i>
        </li>

        <!-- rss -->
        

        
            <li class="tools-item tool-scroll-to-top flex-center">
                <i class="fas fa-arrow-up"></i>
            </li>
        

        <li class="tools-item tool-scroll-to-bottom flex-center">
            <i class="fas fa-arrow-down"></i>
        </li>
    </ul>

    <ul class="exposed-tools-list">
        <li class="tools-item tool-toggle-show flex-center">
            <i class="fas fa-cog fa-spin"></i>
        </li>
        
    </ul>
</div>

    </div>

    <div class="zoom-in-image-mask">
    <img class="zoom-in-image">
</div>


    
        <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
          <span class="search-input-field-pre">
            <i class="fas fa-keyboard"></i>
          </span>
            <div class="search-input-container">
                <input autocomplete="off"
                       autocorrect="off"
                       autocapitalize="off"
                       placeholder="Search..."
                       spellcheck="false"
                       type="search"
                       class="search-input"
                >
            </div>
            <span class="close-popup-btn">
                <i class="fas fa-times"></i>
            </span>
        </div>
        <div id="search-result">
            <div id="no-result">
                <i class="fas fa-spinner fa-pulse fa-5x fa-fw"></i>
            </div>
        </div>
    </div>
</div>

    

</main>




<script src="/js/utils.js"></script>

<script src="/js/main.js"></script>

<script src="/js/header-shrink.js"></script>

<script src="/js/back2top.js"></script>

<script src="/js/dark-light-toggle.js"></script>





    
<script src="/js/local-search.js"></script>




    
<script src="/js/code-block.js"></script>




    
<script src="/js/lazyload.js"></script>



<div class="post-scripts pjax">
    
        
<script src="/js/post-helper.js"></script>

        
            
<script src="/js/libs/anime.min.js"></script>

        
        
            
<script src="/js/toc.js"></script>

        
    
</div>


    
<script src="/js/libs/pjax.min.js"></script>

<script>
    window.addEventListener('DOMContentLoaded', () => {
        window.pjax = new Pjax({
            selectors: [
                'head title',
                '.page-container',
                '.pjax'
            ],
            history: true,
            debug: false,
            cacheBust: false,
            timeout: 0,
            analytics: false,
            currentUrlFullReload: false,
            scrollRestoration: false,
            // scrollTo: true,
        });

        document.addEventListener('pjax:send', () => {
            KEEP.utils.pjaxProgressBarStart();
        });

        document.addEventListener('pjax:complete', () => {
            KEEP.utils.pjaxProgressBarEnd();
            window.pjax.executeScripts(document.querySelectorAll('script[data-pjax], .pjax script'));
            KEEP.refresh();
        });
    });
</script>



</body>
</html>
